//
//  JW_CollectionView.m
//  JWMovie
//
//  Created by Jorn.Wu on 15/7/23.
//  Copyright (c) 2015年 Jorn.Wu. All rights reserved.
//

#import "JW_CollectionView.h"
#import "JW_CollectionViewCell.h"

@implementation JW_CollectionView

- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout{
    if (self = [super initWithFrame:frame collectionViewLayout:layout]) {
        self.backgroundColor = [UIColor clearColor];
        self.delegate = self;
        self.dataSource = self;
        self.pagingEnabled = YES;

        [self registerClass:[JW_CollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
    
    }
    return self;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return self.imageUrlAr.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    JW_CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    cell.imageUrlStr = self.imageUrlAr[indexPath.row];
    
    return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath{
    JW_CollectionViewCell *JW_cell = (JW_CollectionViewCell *)cell;
    UIScrollView *scrollView = (UIScrollView *)JW_cell.scrollView;
    scrollView.zoomScale = 1.f;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    return CGSizeMake(self.bounds.size.width - 10, self.bounds.size.height);
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
